package edu.sias.service;

import edu.sias.dao.SearchDao;
import edu.sias.pojo.Post;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

//业务层
public class SearchService {
    public List<Post> getMsgInfo(String keyMsg){

//业务层 调用 数据层

        SearchDao searchDao = new SearchDao();

        List<Post> posts= searchDao.findMsg(keyMsg);

//假设，对原始数据，按照点击量进行排序

        Collections.sort(posts, new Comparator<Post>() {

            @Override

            public int compare(Post o1, Post o2) {

                return o2.getClick().compareTo(o1.getClick());

            }

        });

//返回处理好的数据

        return posts;

    }

}